package com.tedu.micro.service.stock.controller;

import com.tarena.micro.service.common.result.JsonResult;
import com.tarena.micro.service.pojo.param.StockReduceParam;
import com.tedu.micro.service.stock.service.StockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StockController {
    @Autowired
    private StockService stockService;
    //对外提供减库存的功能 根据接口表格
    @PostMapping("/stock/reduce")
    public JsonResult reduceStock(@RequestBody StockReduceParam param){
        stockService.reduceStock(param.getProductCode(),param.getCount());
        return JsonResult.ok();
    }
    @Value("${server.port}")
    private String port;
    @GetMapping("/stock/hello")
    public String sayHello(){
        return "hello gateway i am from "+port;
    }
}
